package com.example.edu.Controller;

import com.example.edu.Dto.ChapterListDtoG;
import com.example.edu.Dto.Return;
import com.example.edu.Entity.Chapter;
import com.example.edu.Entity.Course;
import com.example.edu.Service.ChapterService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/chapter")
public class ChapterController {
    @Resource
    ChapterService chapterService;

    @PostMapping("/create")
    public Return create(@RequestBody Chapter chapter){
        return chapterService.create(chapter);
    }

    @PostMapping("/getList")
    public Return getList(HttpServletRequest httpServletRequest, @RequestBody ChapterListDtoG chapterListData){
        return chapterService.getList(httpServletRequest,chapterListData);
    }

    @PostMapping("/get")
    public Return get(@RequestBody Chapter chapter){
        return chapterService.get(chapter);
    }

    @PostMapping("/delete")
    public Return delete(@RequestBody Chapter chapter_id){
        return chapterService.delete(chapter_id);
    }

    @PostMapping("/update")
    public Return update(@RequestBody Chapter chapter){
        return chapterService.update(chapter);
    }
}
